package esempio.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name="BOOKING")
public class Booking {
	private long bookingId;
	private Date dateBooking; 
	private Date dateDelivery; 
	private float totalPrice; 
	private String payement;
	private Set<Request> requests = new HashSet<Request>(0);
	
	
	public Booking(Date dateBooking, Date dateDelivery, float totalPrice,
			String payement, Set<Request> requests) {
		
		this.dateBooking = dateBooking;
		this.dateDelivery = dateDelivery;
		this.totalPrice = totalPrice;
		this.payement = payement;
		this.requests = requests;
	}


	public Booking() {
		
	}

	@Id
	@GeneratedValue
	@Column(name="BOOKING_ID")
	public long getBookingId() {
		return bookingId;
	}

	public void setBookingId(long bookingId) {
		this.bookingId = bookingId;
	}
	@Column(name="DATE_BOOKING")
	public Date getDateBooking() {
		return dateBooking;
	}

	public void setDateBooking(Date dateBooking) {
		this.dateBooking = dateBooking;
	}
	@Column(name="DATE_DELIVERY")
	public Date getDateDelivery() {
		return dateDelivery;
	}

	public void setDateDelivery(Date dateDelivery) {
		this.dateDelivery = dateDelivery;
	}
	@Column(name="TOTAL_PRICE")
	public float getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(float totalPrice) {
		this.totalPrice = totalPrice;
	}
	@Column(name="PAYEMENT")
	public String getPayement() {
		return payement;
	}

	public void setPayement(String payement) {
		this.payement = payement;
	}
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "BOOKING_REQUEST", joinColumns = { @JoinColumn(name = "BOOKING_ID") }, inverseJoinColumns = { @JoinColumn(name = "REQUEST_ID") })
	public Set<Request> getRequests() {
		return requests;
	}

	public void setRequests(Set<Request> requests) {
		this.requests = requests;
	}
	
	
	
}
